<div class="panel panel-default">
    <div class="panel-body">
        <div class="form-horizontal form-border">
            <div class="form-group">
                <label class="col-sm-3 control-label">商品名称</label>
                <div class="col-sm-6">
                    <input type="text" id="offer_name" class="form-control" value="$!initData.offer.offer_name">
                </div>
            </div>
            #if($initData.types != 'null')
                <div class="form-group">
                    <label class="col-sm-3 control-label">所属类别</label>
                    <div class="col-sm-6">
                        <select id="type" class="form-control input-sm">
                            #foreach($type in $initData.types)
                                <option value="$type.id"
                                    #if($type.id == $initData.offer.offer_type) selected = "" #end>
                                    $type.offer_type_name</option>
                            #end
                        </select>
                    </div>
                </div>
            #end
            #if($initDate.brands != 'null')
                <div class="form-group">
                    <label class="col-sm-3 control-label">所属品牌</label>
                    <div class="col-sm-6">
                        <select id="offer_brand" class="form-control input-sm">
                            #foreach($brand in $initData.brands)
                                <option value="$brand.id" #if($brand.id == $initData.offer.brand_id) selected = "" #end>
                                    $brand.brand_name</option>
                            #end
                        </select>
                    </div>
                </div>
            #end

            <div class="form-group">
                <label class="col-sm-3 control-label">工厂价</label>
                <div class="col-sm-6">
                    <input type="text" id="in_price" class="form-control" value="$!initData.offer.in_price" placeholder="商品单价（元）">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">售价</label>
                <div class="col-sm-6">
                    <input type="text" id="out_price" class="form-control" value="$!initData.offer.out_price" placeholder="商品单价（元）">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">起售销量</label>
                <div class="col-sm-6">
                    <input type="text" id="saleCnt" class="form-control" value="$!initData.offer.start_sale_num">
                </div>
            </div>

            #if($initData.colors != 'null')
                <div class="form-group">
                    <label class="col-sm-3 control-label">颜色</label>
                    <div class="col-sm-6">
                    #foreach($color in $initData.colors)
                        <label class="radio-inline">
                            <input class="icheck" type="checkbox" value="$color.id" name="color"
                            #foreach($spec in $initData.offer.offerColors)
                                #if($spec.id == $color.id)
                                    checked
                                #end
                            #end
                            >$color.spec_value</label>
                    #end
                    </div>
                </div>
            #end
            #if($initData.lengths)
                <div class="form-group">
                    <label class="col-sm-3 control-label">码数</label>
                    <div class="col-sm-6">
                        #foreach($length in $initData.lengths)
                            <label class="radio-inline">
                                <input class="icheck" type="checkbox" value="$length.id" name="length"
                                    #foreach($offerLength in $initData.offer.offerLengths)
                                        #if($offerLength.id == $length.id)
                                       checked
                                        #end
                                    #end
                                >$length.spec_value</label>
                        #end
                    </div>
                </div>
            #end
            <div class="form-group">
                <label class="col-sm-3 control-label">图片：</label>
                <div class="col-sm-6">
                    <ul class="img-list col-sm-12" id="imageList">
                        #foreach($img in $initData.offer.imgs)
                            <li><img src='http://120.77.86.178:41200$img.url'><i data-img-id="$img.id"></i></li>
                        #end
                    </ul>

                    <div class="col-sm-12 img-add" data-bind="visible: model.formEntity.bannerImgurl().length < 1">
                        <input type="file" placeholder="选择图片" class="form-control"  id="file_sequence_id_1" name="file_sequence_name_2" accept=".jpg,.jpeg,.bmp,.png">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">商品详情</label>
        </div>
        #if($initData.offer.content.content)
            <div class="panel-body panel-body-ext">
                <div id="editor-trigger">$initData.offer.content.content</div>
            </div>

        #else
            <div class="panel-body panel-body-ext">
                <div id="editor-trigger"></div>
            </div>
        #end
        <div class="form-group">
            <div class="col-sm-offset-8 col-sm-2">
                <button type="submit" id="submitBtn" class="btn btn-primary" offerId="$initData.offer.id">确定</button>
                <button type="submit" id="offer-detail-cancel-btn" class="btn btn-primary">取消</button>
            </div>
        </div>
    </div>
</div>
<!--Global JS-->
<script src="/shop/offer/offer/offerdetail.js"></script>
<script>


    var editor = new wangEditor('editor-trigger');

    // 上传图片
    editor.config.uploadImgUrl = 'http://120.77.86.178:8081/upload';
    editor.config.uploadParams = {
        // token1: 'abcde',
        // token2: '12345'
    };
    editor.config.uploadHeaders = {
        // 'Accept' : 'text/x-json'
    }
    // editor.config.uploadImgFileName = 'myFileName';

    // 隐藏网络图片
    // editor.config.hideLinkImg = true;

    // 表情显示项
    editor.config.emotionsShow = 'value';


    // onchange 事件
    editor.onchange = function () {
        console.log(this.$txt.html());
    };

    editor.create();

    function preview(file){
        var prevDiv = document.getElementById('preview');
        if (file.files && file.files[0]){
            var reader = new FileReader();
            reader.onload = function(evt){
                prevDiv.innerHTML = '<img src="' + evt.target.result + '" />';
            }
            reader.readAsDataURL(file.files[0]);
        } else {
            prevDiv.innerHTML =
                    '<div class="img" ' +
                    'style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' +
                    '(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
        }
    }
</script>





